package com.songlanyun.modules.usergains.controller.api;

import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.account.controller.common.AbstractApiController;
import com.songlanyun.modules.shop.service.ShopService;
import com.songlanyun.modules.user.controller.AbstractController;
import com.songlanyun.modules.usergains.entity.UserBill;
import com.songlanyun.modules.usergains.model.AirdropStatisticsVo;
import com.songlanyun.modules.usergains.service.UserBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;


/**
 * 会员分销所得账单
 *
 * @author wuchao
 * @email sunlightcs@gmail.com
 * @date 2020-12-22 15:21:52
 */
@RestController
@RequestMapping("api/usergains/userbill")
public class UserBillApiController extends AbstractApiController {
    @Autowired
    private UserBillService userBillService;

    @Resource
    private ShopService shopService;

    /**
     * 分页列表
     */
    @GetMapping("/page")
    //@RequiresPermissions("usergains:distributionuserbill:list")
    public R page(@RequestParam Map<String, Object> params) {

        params.put("user_id",getUserId(true));
        PageUtils page = userBillService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("usergains:distributionuserbill:list")
    public R list() {

        List<UserBill> list = userBillService.list(getUserId(true));
        return R.ok().put("list", list);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("usergains:distributionuserbill:info")
    public R info(@PathVariable("id") Long id) {
        UserBill distributionUserBill = userBillService.getById(id);

        return R.ok().put("data", distributionUserBill);
    }




}
